const routes = [
    {
        path: '#/home',
        component: '<h1>首页内容</h1>'
    },
    {
        path: '#/about',
        component: '<h1>关于内容</h1>'
    }
]

const routeView = document.querySelector('#routeView')

const bindContent = (target) => {
    let hash = window.location.hash
    let targetRoute = routes.filter(item => item.path === hash)
    if( Array.isArray(targetRoute) && targetRoute.length ){
        routeView.innerHTML = targetRoute[0].component
    }
}

window.addEventListener('hashchange', bindContent)
window.addEventListener('DOMContentLoaded', bindContent)